'use strict';
const BaseController = require('./base');
const { citys } =require('../../city');
const _ = require('lodash');
class UserController extends BaseController {
  /**
   * 编辑
   */
  async getProvinces() {
    const { ctx, service } = this;
    const provinces = citys.map(item => { 
      return {code: item.code, name: item.name};
     });
    ctx.helper.success({
      beans: provinces
    }, '查询省成功');
  }

  async getCitys() {
    const { ctx, service } = this;
    const data = ctx.request.query;
    const { provinceCode = 101010000 } = data;
    let result = citys.find(item => item.code == provinceCode);
    result = result ? result.subLevelModelList : [];
    ctx.helper.success({
      beans: result
    }, '查询市成功');
  }


  
}

module.exports = UserController;
